package com.xiaohudie.SGGio;

import java.io.*;

/**
 * @Author xiao hu die
 * @Date 2022/3/27 1:26
 * @Version 1.0
 */
public class ObjectOutStreamTest {
 public static void main(String[] args) {
  ObjectInputStream objectInputStream =null;
  ObjectOutputStream objectOutputStream = null;
  try {
   objectOutputStream = new ObjectOutputStream(new FileOutputStream("D:\\java图片代码\\data.txt"));
   objectOutputStream.writeObject(new Student("刘碟","21",1));
   objectInputStream =new ObjectInputStream(new FileInputStream("D:\\java图片代码\\data.txt"));
   Object o = objectInputStream.readObject();
   Student student =(Student) o;
   System.out.println(student.getName());
  }catch (Exception e){
   e.printStackTrace();
  }finally {
   try {
    objectOutputStream.close();
   } catch (IOException e) {
    e.printStackTrace();
   }
  }
 }
}
